#include "stdio.h"
#include "stdint.h"
#include <string.h>
#include <stdlib.h>

#define MSEC_PER_SEC                                                ((TimeMSec)1000)
#define MSEC_PER_USEC                                               ((TimeMSec)1000)


#define MCXT_ALLOC_HUGE            0x01    /* allow huge allocation (> 1 GB) not
										 * actually used for frontends */
#define MCXT_ALLOC_NO_OOM        0x02    /* no failure if out-of-memory */
#define MCXT_ALLOC_ZERO            0x04    /* zero allocated memory */
#define EXIT_FAILURE 1
#define LONG_ALIGN_MASK (sizeof(long) - 1)
#define MEMSET_LOOP_LIMIT 1024


typedef size_t Size;


#define MemSet(start, val, len) \
    do \
    { \
        /* must be void* because we don't know if it is integer aligned yet */ \
        void   *_vstart = (void *) (start); \
        int        _val = (val); \
        Size    _len = (len); \
\
        if ((((uintptr_t) _vstart) & LONG_ALIGN_MASK) == 0 && \
            (_len & LONG_ALIGN_MASK) == 0 && \
            _val == 0 && \
            _len <= MEMSET_LOOP_LIMIT && \
            /* \
			 *	If MEMSET_LOOP_LIMIT == 0, optimizer should find \
			 *	the whole "if" false at compile time. \
			 */ \
            MEMSET_LOOP_LIMIT != 0) \
        { \
            long *_start = (long *) _vstart; \
            long *_stop = (long *) ((char *) _start + _len); \
            while (_start < _stop) \
                *_start++ = 0; \
        } \
        else \
            memset(_vstart, _val, _len); \
    } while (0)


static inline void *
qb_malloc_internal(size_t size, int flags) {
    void *tmp;

    /* Avoid unportable behavior of malloc(0) */
    if (size == 0)
        size = 1;
    tmp = malloc(size);
    if (tmp == NULL) {
        if ((flags & MCXT_ALLOC_NO_OOM) == 0) {
            printf("out of memory\n");
            exit(EXIT_FAILURE);
        }
        return NULL;
    }

    if ((flags & MCXT_ALLOC_ZERO) != 0)
        MemSet(tmp, 0, size);
    return tmp;
}

void *
palloc(Size size) {
    return qb_malloc_internal(size, 1);
}


void
qb_free(void *ptr) {
    if (ptr != NULL)
        free(ptr);
}

void
pfree(void *pointer) {
    qb_free(pointer);
}


typedef struct {
    int a;
} sa, *sa_t;

typedef struct {
    sa a;
    int b;
} sb, *sb_t;

int main() {
    char *a = "123";
    printf("%s\n", a);
}